package client;

import java.awt.event.ActionListener;

public class WelcomePanel extends javax.swing.JPanel
{
    public static final int VIEW_RESULTS_CHOSEN = 2;
    public static final int REGISTER_CHOSEN = 1;
    public static final int VOTE_CHOSEN = 0;
    public static final int NOTHING_CHOSEN = -1;

    /** Creates new form WelcomePanel */
    public WelcomePanel()
    {
        initComponents();
    }

    public void addRadioButtonsActionListener( ActionListener l )
    {
        voteRadioButton.addActionListener( l );
        registerRadioButton.addActionListener( l );
        viewResultsRadioButton.addActionListener( l );
    }

    public int choice()
    {
        if( voteRadioButton.isSelected() )
            return VOTE_CHOSEN;
        if( registerRadioButton.isSelected() )
            return REGISTER_CHOSEN;
        if( viewResultsRadioButton.isSelected() )
            return VIEW_RESULTS_CHOSEN;
        return NOTHING_CHOSEN;
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings( "unchecked" )
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents()
    {
        buttonGroup1 = new javax.swing.ButtonGroup();
        jLabel1 = new javax.swing.JLabel();
        registerRadioButton = new javax.swing.JRadioButton();
        voteRadioButton = new javax.swing.JRadioButton();
        viewResultsRadioButton = new javax.swing.JRadioButton();
        jLabel1.setText( "I want to:" );
        buttonGroup1.add( registerRadioButton );
        registerRadioButton.setText( "register" );
        buttonGroup1.add( voteRadioButton );
        voteRadioButton.setText( "vote" );
        buttonGroup1.add( viewResultsRadioButton );
        viewResultsRadioButton.setText( "view results" );
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout( this );
        this.setLayout( layout );
        layout.setHorizontalGroup( layout
                .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                .addGap( 0, 400, Short.MAX_VALUE )
                .addGroup(
                    layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(
                                layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                        .addComponent( jLabel1 )
                                        .addGroup(
                                            layout.createSequentialGroup()
                                                    .addGap( 12, 12, 12 )
                                                    .addGroup(
                                                        layout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                                                                .addComponent( registerRadioButton ).addComponent( viewResultsRadioButton )
                                                                .addComponent( voteRadioButton ) ) ) )
                            .addContainerGap( 303, Short.MAX_VALUE ) ) );
        layout.setVerticalGroup( layout
                .createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING )
                .addGap( 0, 300, Short.MAX_VALUE )
                .addGroup(
                    layout.createSequentialGroup().addContainerGap().addComponent( jLabel1 )
                            .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( voteRadioButton )
                            .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( viewResultsRadioButton )
                            .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED ).addComponent( registerRadioButton )
                            .addContainerGap( 215, Short.MAX_VALUE ) ) );
    }// </editor-fold>
     // Variables declaration - do not modify

    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JRadioButton registerRadioButton;
    private javax.swing.JRadioButton voteRadioButton;
    private javax.swing.JRadioButton viewResultsRadioButton;
    // End of variables declaration
}